package springProvider.health;

import java.util.Date;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
//import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class MyHealthindicator implements HealthIndicator{
	//状态
	private static Boolean state = true;
	@Override
	public Health health() {
		
		 
		//如果链接正常则返回正常状态
		if(state)return new Health.Builder(Status.UP).build();
		//如果连接不正常则返回不正常状态
		return  new Health.Builder(Status.DOWN).build();
	}
	
	//@Scheduled(initialDelay = 1000,fixedRate = 30000)
	public void checkQuelqueChouse() {
		Boolean flag = false;
		if(new Date().getTime()%2==0)flag = true;
		else flag = false;
		System.out.println("设置健康状态 "+flag);
		state = true;
	}

}
